package com.mask.statistics.schedule;

import com.mask.statistics.service.StatisticsDailyService;
import com.mask.statistics.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 数据统计定时任务
 * @author hx
 */
@Component
@Slf4j
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService staService;

    /**
     * 在每天凌晨1点，把前一天数据进行数据查询添加
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void task2() {
        log.info("日注册用户数据统计中...");
        staService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
        log.info("日注册数据统计结束...");
    }
}
